$('header').height($(window).height()/2);
/*登陆验证*/
var uName = "";
var uPwd = "";
$("#loginBtn").click(function () {
    uName = $("#uName").val();
    uPwd = $("#uPwd").val();
    if (uName == "") {
    	$("#msg").text("请输入用户名！").show();
        return;
    } else if (uPwd == "") {
        $("#msg").text("请输入密码！").show();
        return;
    } else {
    	verify();        
    }
});
/*监听输入框值变化*/
$("#uName,#uPwd").on("input propertychange", function () {
    var $this=$(this);
    var myStr=$this.val();
    if(myStr.length > 0){
        $this.next().show();
    }else{
        $this.next().hide();
    }
});
$("#uName,#uPwd").blur(function(){
    var $this=$(this);
    $this.next().hide();
});
/*清空表单*/
$(".clear").click(function () {
    var $this = $(this);
    $this.prev().val("");
    $this.hide();
});

function verify(){
	$.ajax({
	    url:'loginAction.do',
	    type:'POST', 
	    data:{
	    	userName : uName,
			passWord : uPwd
	    },
	    dataType:'json',
	    success:function(args){
	        if(args.code == "succ"){
		    	$("#msg").text('').hide();
		    	var storage=window.localStorage;	           
	            storage.setItem("userInfo",JSON.stringify(args.currentUser));
		    	window.location.href = 'html/login/main.html';
		    }else{
		    	$("#msg").text("账号或密码错误！").show();
		    }
	    },
	    error:function(){
	        console.log('错误');
	    },
	    complete:function(){
	        console.log('结束');
	    }
	});
}